package com.idp.web.test.service.impl;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.google.gson.Gson;
import com.idp.common.model.KdniaoJsonBean;
import com.idp.common.util.KdniaoTrackQueryAPI;
import com.idp.web.test.service.LogisticsInfoSearchService;

/**
 *
 *
 * @author Mao
 * @date 2017年6月30日
 *
 */
@Service("logisticsInfoSearchService")
public class LogisticsInfoSearchServiceImpl implements LogisticsInfoSearchService {
	
	@Value("${EBusinessID}")
	private String EBusinessID;
	@Value("${AppKey}")
	private String AppKey;

	@Override
	public KdniaoJsonBean searchLogisticsInfo(String ShipperCode, String LogisticCode) {
		KdniaoTrackQueryAPI api = new KdniaoTrackQueryAPI();
		try {
			System.err.println("EBusinessID ++++" + EBusinessID);
			System.err.println("AppKey ++++" + AppKey);
			String result = api.getOrderTracesByJson(ShipperCode, LogisticCode, EBusinessID, AppKey);
			System.err.println("查询快递物流信息 " + result);
			Gson gson = new Gson();
			KdniaoJsonBean pojo = gson.fromJson(result, KdniaoJsonBean.class);
			return pojo;
		} catch (Exception e) {
			e.printStackTrace();
			System.err.println("查询快递物流信息出错，请验证信息!");
		}
		return null;
	}

}
